// import React, { Component } from 'react'
// import { connect } from 'react-redux'
// import { View, Button, Text } from '@tarojs/components'

// import { add, minus, asyncAdd } from '../../actions/counter'

// import './index.scss'


// @connect(({ counter }) => ({
//   counter
// }), (dispatch) => ({
//   add () {
//     dispatch(add())
//   },
//   dec () {
//     dispatch(minus())
//   },
//   asyncAdd () {
//     dispatch(asyncAdd())
//   }
// }))
// class Index extends Component {
//   componentWillReceiveProps (nextProps) {
//     console.log(this.props, nextProps)
//   }

//   componentWillUnmount () { }

//   componentDidShow () { }

//   componentDidHide () { }

//   render () {
//     return (
//       <View className='index'>
//         <Button className='add_btn' onClick={this.props.add}>+</Button>
//         <Button className='dec_btn' onClick={this.props.dec}>-</Button>
//         <Button className='dec_btn' onClick={this.props.asyncAdd}>async</Button>
//         <View><Text>{this.props.counter.num}</Text></View>
//         <View><Text>Hello, World</Text></View>
//       </View>
//     )
//   }
// }

// export default Index


import React, { useEffect } from 'react'
import { View } from '@tarojs/components'

import Taro from '@tarojs/taro'

// import Test from '@/components/Test'
import Test from '../test/Test'
import set_title from '../../utils/title'

import './index.scss'

let {
  useReady,
  useDidShow,
  useDidHide,
  usePullDownRefresh,
  useTitleClick
} = Taro

function Index () {
  // 可以使用所有的 React Hooks
  useEffect(() => {
    // console.log(app.aaa)
  })
  
  const app = Taro.getApp()
  console.log(app)
  // 对应 onReady
  useReady(() => {
    set_title('aaaaaaaa')

  })

  useTitleClick((options) => {
    console.log(options)
  })

  // 对应 onShow
  useDidShow(() => {})

  // 对应 onHide
  useDidHide(() => {})

  const handleClick = () => {
    Taro.navigateTo({
      url: '/pages/detail/Detail?id=100'
    })
  }

  // Taro 对所有小程序页面生命周期都实现了对应的自定义 React Hooks 进行支持
  // 详情可查阅：【Taro 文档】-> 【进阶指南】->【Hooks】
  usePullDownRefresh(() => {})

  return (
    <>
      <View className='index' onClick={handleClick}>hello</View>
      <Test></Test>
      {/* {
        process.env.TARO_ENV === 'weapp' && <view>weapp</view>
      }
      {
        process.env.TARO_ENV === 'h5' && <div>h5</div>
      } */}
    </>
  )
}

export default Index
